<?php

use yii\db\Migration;

class m211211_060136_auth_item extends Migration
{
    public function up()
    {
        /* 取消外键约束 */
        $this->execute('SET foreign_key_checks = 0');
        
        /* 创建表 */
        $this->createTable('{{%auth_item}}', [
            'id' => "int(11) NOT NULL AUTO_INCREMENT",
            'name' => "varchar(64) NOT NULL",
            'type' => "smallint(6) NOT NULL COMMENT '0系统1模块'",
            'description' => "text NULL",
            'rule_name' => "int(11) NULL DEFAULT '0'",
            'parent_id' => "int(11) NULL",
            'permission_type' => "int(11) NULL COMMENT '权限类型:0: 目录1: 页面 2: 按钮 3: 接口'",
            'data' => "blob NULL",
            'module_name' => "varchar(50) NULL",
            'created_at' => "int(11) NULL",
            'updated_at' => "int(11) NULL",
            'PRIMARY KEY (`id`)'
        ], "ENGINE=InnoDB  DEFAULT CHARSET=utf8");
        
        /* 索引设置 */
        $this->createIndex('rule_name','{{%auth_item}}','rule_name',0);
        $this->createIndex('type','{{%auth_item}}','type',0);
        $this->createIndex('name','{{%auth_item}}','name',0);
        
        
        /* 表数据 */
        $this->insert('{{%auth_item}}',['id'=>'2','name'=>'人脸识别','type'=>'0','description'=>NULL,'rule_name'=>NULL,'parent_id'=>'1','permission_type'=>NULL,'data'=>NULL,'module_name'=>'sys','created_at'=>'1582139583','updated_at'=>'1582141300']);
        $this->insert('{{%auth_item}}',['id'=>'6','name'=>'开发示例','type'=>'0','description'=>NULL,'rule_name'=>NULL,'parent_id'=>'0','permission_type'=>NULL,'data'=>NULL,'module_name'=>'sys','created_at'=>'1585611530','updated_at'=>'1585611530']);
        $this->insert('{{%auth_item}}',['id'=>'7','name'=>'扩展功能','type'=>'0','description'=>NULL,'rule_name'=>NULL,'parent_id'=>'0','permission_type'=>NULL,'data'=>NULL,'module_name'=>'sys','created_at'=>'1582139605','updated_at'=>'1582139605']);
        $this->insert('{{%auth_item}}',['id'=>'8','name'=>'权限控制','type'=>'0','description'=>NULL,'rule_name'=>NULL,'parent_id'=>'0','permission_type'=>NULL,'data'=>NULL,'module_name'=>'sys','created_at'=>'1582139364','updated_at'=>'1582139364']);
        $this->insert('{{%auth_item}}',['id'=>'9','name'=>'模块生成','type'=>'0','description'=>NULL,'rule_name'=>NULL,'parent_id'=>'0','permission_type'=>NULL,'data'=>NULL,'module_name'=>'sys','created_at'=>'1585473562','updated_at'=>'1585473562']);
        $this->insert('{{%auth_item}}',['id'=>'10','name'=>'模块统一入口','type'=>'0','description'=>NULL,'rule_name'=>NULL,'parent_id'=>'0','permission_type'=>NULL,'data'=>NULL,'module_name'=>'sys','created_at'=>'1588808930','updated_at'=>'1588808930']);
        $this->insert('{{%auth_item}}',['id'=>'12','name'=>'测试实施','type'=>'0','description'=>NULL,'rule_name'=>NULL,'parent_id'=>'0','permission_type'=>NULL,'data'=>NULL,'module_name'=>'sys','created_at'=>'1588573267','updated_at'=>'1588573267']);
        $this->insert('{{%auth_item}}',['id'=>'13','name'=>'站点管理','type'=>'0','description'=>NULL,'rule_name'=>NULL,'parent_id'=>'0','permission_type'=>NULL,'data'=>NULL,'module_name'=>'sys','created_at'=>'1582139575','updated_at'=>'1582139575']);
        $this->insert('{{%auth_item}}',['id'=>'14','name'=>'管理员管理','type'=>'0','description'=>NULL,'rule_name'=>NULL,'parent_id'=>'0','permission_type'=>NULL,'data'=>NULL,'module_name'=>'sys','created_at'=>'1588779477','updated_at'=>'1588779477']);
        $this->insert('{{%auth_item}}',['id'=>'15','name'=>'系统设置','type'=>'0','description'=>NULL,'rule_name'=>NULL,'parent_id'=>'0','permission_type'=>NULL,'data'=>NULL,'module_name'=>'sys','created_at'=>'1582139568','updated_at'=>'1582139568']);
        $this->insert('{{%auth_item}}',['id'=>'19','name'=>'资源上传','type'=>'0','description'=>NULL,'rule_name'=>NULL,'parent_id'=>'0','permission_type'=>NULL,'data'=>NULL,'module_name'=>'sys','created_at'=>'1585451956','updated_at'=>'1585451956']);
        $this->insert('{{%auth_item}}',['id'=>'29','name'=>'数据库','type'=>'0','description'=>NULL,'rule_name'=>NULL,'parent_id'=>'15','permission_type'=>NULL,'data'=>NULL,'module_name'=>'sys','created_at'=>'1592915692','updated_at'=>'1592915723']);
        $this->insert('{{%auth_item}}',['id'=>'45','name'=>'商户选择','type'=>'0','description'=>NULL,'rule_name'=>NULL,'parent_id'=>'15','permission_type'=>NULL,'data'=>NULL,'module_name'=>'sys','created_at'=>'1614077853','updated_at'=>'1614077853']);
        $this->insert('{{%auth_item}}',['id'=>'48','name'=>'权限测试','type'=>'0','description'=>'商户删除','rule_name'=>'1','parent_id'=>'1','permission_type'=>NULL,'data'=>'i:23;','module_name'=>NULL,'created_at'=>'1621328788','updated_at'=>'1621328788']);
        $this->insert('{{%auth_item}}',['id'=>'49','name'=>'酒店权限','type'=>'0','description'=>'酒店','rule_name'=>'1','parent_id'=>'1','permission_type'=>NULL,'data'=>NULL,'module_name'=>NULL,'created_at'=>'1621328841','updated_at'=>'1621328841']);
        $this->insert('{{%auth_item}}',['id'=>'50','name'=>'酒店权限','type'=>'0','description'=>'酒店','rule_name'=>'1','parent_id'=>'1','permission_type'=>NULL,'data'=>NULL,'module_name'=>NULL,'created_at'=>'1621329000','updated_at'=>'1621329000']);
        $this->insert('{{%auth_item}}',['id'=>'51','name'=>'目录测试18','type'=>'0','description'=>'描述','rule_name'=>NULL,'parent_id'=>'0','permission_type'=>'1','data'=>NULL,'module_name'=>'sys','created_at'=>'1621837243','updated_at'=>'1621838245']);
        $this->insert('{{%auth_item}}',['id'=>'54','name'=>'站点设置','type'=>'0','description'=>NULL,'rule_name'=>NULL,'parent_id'=>'15','permission_type'=>'0','data'=>NULL,'module_name'=>'sys','created_at'=>'1635403574','updated_at'=>'1635403574']);
        
        /* 设置外键约束 */
        $this->execute('SET foreign_key_checks = 1;');
    }

    public function down()
    {
        $this->execute('SET foreign_key_checks = 0');
        /* 删除表 */
        $this->dropTable('{{%auth_item}}');
        $this->execute('SET foreign_key_checks = 1;');
    }
}

